package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-10-24
 * Time: 20:05
 */

class Animal {
    public String name;
    public int age;

    public Animal() {
        System.out.println("不带参数Animal!");
    }
    static {
        System.out.println("Animal静态代码块!");
    }

    {
        System.out.println("Animal构造代码块!");
    }
    public void eat() {
        System.out.println(this.name + " 在吃饭!");
    }
}

class Dog extends Animal {
    String fad;

    static {
        System.out.println("Dog静态代码块!");
    }

    {
        System.out.println("Dog构造代码块!");
    }

    public Dog() {
        // super(name, age);
        // this.fad = fad;
        System.out.println("不带参数Dog!");
    }
     public void bark() {
         System.out.println(this.name + " 在汪汪汪!");
     }
}

class Cat extends Animal {

    public Cat() {
        // super("小黄", 10);
        System.out.println("不带参数Cat!");
    }

    static {
        System.out.println("Cat静态代码块!");
    }

    {
        System.out.println("Cat构造代码块!");
    }

    public void mimi() {
        System.out.println(this.name + " 在喵喵喵!");
    }
}
public class TestDemo {
    public static void main(String[] args) {
        Dog dog = new Dog();
        System.out.println("===========");
        Cat cat = new Cat();
    }

    public static void main1(String[] args) {
        Dog dog = new Dog();
        dog.eat();
        dog.bark();
        System.out.println("============");

        Cat cat = new Cat();
        cat.name = "小花";
        cat.age = 10;
        cat.eat();
        cat.mimi();
    }
}
